#ifndef FAVORITESPANEL_H
#define FAVORITESPANEL_H
#include <QWidget>
#include "../utils/heapdump.h"

class QPushButton;
class QStackedLayout;
class QMenu;
class QAbstractItemModel;
class QTreeView;
class QModelIndex;

namespace ExecTerminalImplNS
{
    class AutoExclusiveButton;
    class FavoritesModel;
    class FavoritesItemFilterModel;
    class FavoritesItemEditDialogImpl;
    class FavoritesPanel: public QWidget
    {
        Q_OBJECT

    public:
        FavoritesPanel(QWidget * parent);
        ~FavoritesPanel()
        {
            heapdump();
        }
    
        FavoritesModel * favoritesModel()const;
        void setFilterPattern(const QString & );

    public slots:
        void addItem(const QString & name, 
            const QString & url, 
            const QPixmap & icon = QPixmap());

    signals:
        void urlSelected(const QString &);

    protected slots:
        void addFolder();
        void removeItem();
        void updateCurrentView();
        void sortFavoritesItems();
        void renameCurrentItem();
        void editCurrentItemProperties();
        void translateIndexToAddresAndEmit(const QModelIndex &);

    protected: 
        void layoutComponents();
        void resizeEvent(QResizeEvent *);
        void paintEvent(QPaintEvent *);
        void contextMenuEvent(QContextMenuEvent *);

    private:
        void createAllObjects();
        void initModelViews();
        void initButtons();
        void initLayout();
        void initContextMenu();

        int activePage()const;
        QAbstractItemModel * activeModel();
        QTreeView * activeView();

    private:
        QTreeView * theGeneralFavorites;
        FavoritesModel * theGeneralFavoritesModel;
        QTreeView/*new QTreeView(theContainerWidget);//*/ * theLocalFavorites;
        FavoritesItemFilterModel * theFavoritesFilterModel;
        QPushButton * theAddFolderButton;
        QPushButton * theRemoveItemButton;
        AutoExclusiveButton * theGeneralFavoritesButton;
        AutoExclusiveButton * theLocalFavoritesButton;
        QWidget * theContainerWidget;
        QStackedLayout * thePageLayout;
        QMenu * theContextMenu;
        FavoritesItemEditDialogImpl * theItemEditDialog;

    };
}

#endif
